/* -------------------------------------------------------------------------
 *  This file is part of the Cantian project.
 * Copyright (c) 2024 Huawei Technologies Co.,Ltd.
 *
 * Cantian is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *          http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * -------------------------------------------------------------------------
 *
 * knl_syncpoint.h
 *
 *
 * IDENTIFICATION
 * src/kernel/common/knl_syncpoint.h
 *
 * -------------------------------------------------------------------------
 */
#ifndef __KNL_SYNCPOINT_H__
#define __KNL_SYNCPOINT_H__

#include "cm_defs.h"
#include "cm_spinlock.h"
#include "knl_interface.h"

#ifdef __cplusplus
extern "C"{
#endif

#ifdef DB_DEBUG_VERSION
#define KNL_MAX_SYNCPOINT_NAME_LEN 64
#define CANTIAN_MEMORY_LEAK_SIZE (1024 * 1024 * 100)

typedef enum {
    CANTIAN_MEMORY_LEAK,
    CANTIAN_DCS_REQUEST_PAGE_OWNER_ABORT,
    CANTIAN_DCS_REQUEST_PAGE_INTERNAL_FAIL,
    SYNCPOINT_ID_CLEAN_PAGE_OWNER_MALLOC_NULL,
    CANTIAN_DCS_ASK_MASTER_SEND_FAIL,
    CANTIAN_DCS_ASK_MASTER_SUCC_ABORT,
    CANTIAN_DCS_PROC_ASK_MASTER_ABORT,
    CANTIAN_DCS_NOTIFY_OWNER_SEND_FAIL,
    CANTIAN_DCS_NOTIFY_OWNER_SUCC_ABORT,
    CANTIAN_DCS_TRANSFER_BEFORE_SEND_ABORT,
    CANTIAN_DCS_TRANSFER_AFTER_SEND_ABORT,
    CANTIAN_DCS_ASK_MASTER_ACK_SUCC_ABORT,
    CANTIAN_DCS_CLAIM_OWNER_SEND_FAIL,
    CANTIAN_DCS_MASTER_BEFORE_CLAIM_ABORT,
    CANTIAN_DCS_INVALID_PROC_ABORT,
    CANTIAN_DCS_SEND_EDP_MESSAGE_FAIL,
    CANTIAN_DCS_INVALID_REQ_OTHER_ABORT,
    CANTIAN_DCS_RECYCLE_ITEM_OTHER_ABORT,
    CANTIAN_DCS_RECYCLE_ITEM_PENDING_OTHER_ABORT,
    CANTIAN_DCS_RECYCLE_OWNER_SEND_FAIL,
    CANTIAN_DCS_RECYCLE_MASTER_OTHER_ABORT,

    CANTIAN_HEAP_EXTEND_PROC_BCAST_ABORT,
    CANTIAN_HEAP_EXTEND_UNSET_BEFORE_BCAST_ABORT,
    CANTIAN_BTREE_SPLIT_AFTER_BCAST_SPLITTING_ABORT,
    CANTIAN_BTREE_SPLIT_ALLOC_EXTENT_FAIL,
    CANTIAN_BTREE_SPLIT_BEFORE_BCAST_ABORT_SPLIT_ABORT,
    CANTIAN_BTREE_SPLIT_BEFORE_BCAST_SPLITTED_ABORT,
    CANTIAN_SYNC_DDL_BEFORE_BCAST_ABORT,
    CANTIAN_PROC_DDL_BCAST_ABORT,
    CANTIAN_INVALID_DC_BEFORE_BCAST_ABORT,
    CANTIAN_DTC_BCAST_ACK_FAIL,
    CANTIAN_DROP_USER_LOCK_AFTER_BCAST_ABORT,
    CANTIAN_DROP_USER_OBJECT_FAIL,
    CANTIAN_DROP_USER_REVERT_NORMAL_BEFORE_BCAST_ABORT,
    CANTIAN_DROP_USER_LOCK_PROC_BCAST_ABORT,
    CANTIAN_DROP_USER_REVERT_NORMAL_PROC_BCAST_ABORT,
    CANTIAN_BTREE_BEFORE_BCAST_ROOT_PAGE_ABORT,
    CANTIAN_BTREE_AFTER_BCAST_ROOT_PAGE_ABORT,
    CANTIAN_BTREE_PROC_BCAST_ROOT_PAGE_FAIL,
    CANTIAN_BTREE_PROC_BCAST_ROOT_PAGE_ABORT,
    CANTIAN_TXN_INF_REQ_SEND_FAIL,
    CANTIAN_TXN_INF_ACK_SEND_FAIL,
    CANTIAN_TXN_SNAPSHOT_REQ_SEND_FAIL,
    CANTIAN_TXN_SNAPSHOT_ACK_SEND_FAIL,
    CANTIAN_TXN_WAIT_SEND_FAIL,
    CANTIAN_DLS_WAIT_TXN_SEND_FAIL,
    CANTIAN_DLS_WAIT_TXN_ACK_SEND_FAIL,
    CANTIAN_PCR_REQ_HEAP_PAGE_SEND_FAIL,
    CANTIAN_PCR_REQ_BTREE_PAGE_SEND_FAIL,
    CANTIAN_PCR_ACK_FAIL,
    CANTIAN_PCR_REQ_MASTER_SEND_FAIL,
    CANTIAN_PCR_REQ_OWNER_SEND_FAIL,
    CANTIAN_HEAP_CHECK_VISIBLE_SEND_FAIL,
    CANTIAN_HEAP_CHECK_VISIBLE_ACK_FAIL,
    CANTIAN_REFORM_BUILD_CHANNEL_FAIL,
    CANTIAN_RECOVERY_INIT_FAIL,
    CANTIAN_PARAL_REPLAY_READ_LOG_FAIL,
    CANTIAN_RECOVERY_ANAL_READ_LOG_FAIL,
    CANTIAN_RECOVERY_RCY_SET_ALLOC_ITEMPOOL_FAIL,
    CANTIAN_RECOVERY_SEND_RCY_SET_FAIL,
    CANTAIN_RECOVERY_PROC_RCY_SET_MALLOC_NULL,
    CANTIAN_RECOVERY_SEND_RCY_SET_ACK_FAIL,
    CANTIAN_PART_RECOVERY_BEFORE_CKPT_ABORT,
    CANTIAN_SMON_REQUEST_TXN_DLOCK_TIMEOUT_AND_FAIL,
    CANTIAN_SMON_REQUEST_SID_TIMEOUT_AND_FAIL,
    CANTIAN_SMON_REQUEST_WSID_TIMEOUT_AND_FAIL,
    CANTIAN_DLS_LOCK_REMOTE_TABLE_ABORT,
    CANTIAN_REMASTER_SEND_TASK_FAIL,
    CANTIAN_REMASTER_SEND_MIGRATE_BUF_RES_FAIL,
    CANTIAN_REMASTER_SEND_MIGRATE_LOCK_RES_FAIL,
    CANTIAN_REMASTER_BCAST_TARGET_PART_FAIL,
    CANTIAN_REMASTER_BCAST_REMASTER_DONE_FAIL,
    CANTIAN_REMASTER_STEP_ASSIGN_TASK_FAIL,
    CANTIAN_REMASTER_STEP_MIGRATE_FAIL,
    CANTIAN_REMASTER_STEP_RECOVERY_FAIL,
    CANTIAN_REMASTER_STEP_PUBLISH_FAIL,
    CANTIAN_REMASTER_CREATE_FREE_MIGRATE_PROC_FAIL,
    CANTIAN_REMASTER_CREATE_CLEAN_OWNER_PROC_FAIL,
    CANTIAN_REMASTER_CREATE_LOCKRES_RCY_PROC_FAIL,
    CANTIAN_REMASTER_CREATE_COLLECT_PAGEINFO_PROC_FAIL,
    CANTIAN_REMASTER_CREATE_MIGRATE_RES_PROC_FAIL,
    CANTIAN_BCAST_RECOVERY_DONE_OTHER_ABORT,
    CANTIAN_BCAST_REFORM_DONE_OTHER_ABORT,
    CANTIAN_DLS_REQUEST_LOCK_OWNER_FAIL,
    CANTIAN_DLS_REQUEST_LOCK_OWNER_SUCC_ABORT,
    CANTIAN_DLS_REQUEST_LOCK_MSG_SEND_FAIL,
    CANTIAN_DLS_REQUEST_LOCK_MSG_SEND_SUCC_ABORT,
    CANTIAN_DLS_CLAIM_LOCK_OWNER_FAIL,
    CANTIAN_DLS_CLAIM_LOCK_OWNER_SUCC_ABORT,
    CANTIAN_DLS_CLAIM_LOCK_OWNER_BEFORE_ABORT,
    CANTIAN_DDL_CREATE_TMP_TABLE_BEFORE_CREATE_LTT_ABORT,
    CANTIAN_DDL_CREATE_TMP_TABLE_AFTER_CREATE_LTT_ABORT,
    CANTIAN_DDL_DROP_TMP_TABLE_BEFORE_RELEASE_LTT_ABORT,
    CANTIAN_DDL_DROP_TMP_TABLE_AFTER_RELEASE_LTT_ABORT,
    CANTIAN_DDL_CREATE_TABLE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_CREATE_TABLE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_CREATE_TABLE_FAIL,
    CANTIAN_DDL_CREATE_TABLE_HANDLE_REFS_FAIL,
    CANTIAN_DDL_DROP_TABLE_AFTER_LOG_PUT,
    CANTIAN_DDL_DROP_TABLE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_DROP_TABLE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_TABLE_FAIL,
    CANTIAN_DDL_ALTER_TABLE_AFTER_LOG_PUT,
    CANTIAN_DDL_ALTER_TABLE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_ALTER_TABLE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_ALTER_TABLE_RETURN_ERROR,
    CANTIAN_DDL_CREATE_HASH_PART_INDEX_BEFORE_WRITE_UNDO_ABORT,
    CANTIAN_DDL_CREATE_HASH_PART_INDEX_AFTER_WRITE_UNDO_ABORT,
    CANTIAN_DDL_CREATE_HASH_PART_HEAP_SEG_BEFORE_WRITE_UNDO_ABORT,
    CANTIAN_DDL_CREATE_HASH_PART_HEAP_SEG_AFTER_WRITE_UNDO_ABORT,
    CANTIAN_DDL_CREATE_USER_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_CREATE_USER_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_USER_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_DROP_USER_AFTER_SYNC_ABORT,
    CANTIAN_DDL_ALTER_USER_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_ALTER_USER_AFTER_SYNC_ABORT,
    CANTIAN_DDL_CREATE_INDEX_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_CREATE_INDEX_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_INDEX_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_DROP_INDEX_AFTER_SYNC_ABORT,
    CANTIAN_DDL_ALTER_INDEX_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_ALTER_INDEX_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_SPACE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_CREATE_DATAFILE_BEFORE_CREATE_DF_ABORT,
    CANTIAN_DDL_CREATE_DATAFILE_FAIL,
    CANTIAN_DDL_CREATE_DATAFILE_AFTER_CREATE_DF_ABORT,
    CANTIAN_DDL_CREATE_DATAFILE_BEFORE_SAVE_CTRL_ABORT,
    CANTIAN_DDL_CREATE_DATAFILE_SAVE_DF_CTRL_FAIL,
    CANTIAN_DDL_CREATE_DATAFILE_SAVE_SPC_CTRL_FAIL,
    CANTIAN_DDL_CREATE_DATAFILE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_CREATE_DATAFILE_AFTER_SYNC_DDL_ABORT,
    CANTIAN_DDL_EXTEND_DATAFILE_BEFORE_LOG_COMMIT_ABORT,
    CANTIAN_DDL_EXTEND_DATAFILE_BEFORE_EXTEND_DEVICE_ABORT,
    CANTIAN_DDL_EXTEND_DATAFILE_FAIL,
    CANTIAN_DDL_EXTEND_DATAFILE_BEFORE_SAVE_DF_CTRL_ABORT,
    CANTIAN_DDL_EXTEND_DATAFILE_SAVE_DF_CTRL_FAIL,
    CANTIAN_DDL_EXTEND_DATAFILE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_EXTEND_DATAFILE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_REMOVE_DATAFILE_BEFORE_LOGPUT_ABORT,
    CANTIAN_DDL_REMOVE_DATAFILE_AFTER_LOGPUT_ABORT,
    CANTIAN_DDL_REMOVE_DATAFILE_SAVE_SPC_CTRL_FAIL,
    CANTIAN_DDL_REMOVE_DATAFILE_AFTER_WRITE_SPACECTRL_ABORT,
    CANTIAN_DDL_REMOVE_DATAFILE_SAVE_DF_CTRL_FAIL,
    CANTIAN_DDL_REMOVE_DATAFILE_FAIL,
    CANTIAN_DDL_REMOVE_DATAFILE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_REMOVE_DATAFILE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_TRUNCATE_DATAFILE_BEFORE_LOG_COMMIT_ABORT,
    CANTIAN_DDL_TRUNCATE_DATAFILE_BEFORE_TRUNCATE_DEVICE_ABORT,
    CANTIAN_DDL_TRUNCATE_DATAFILE_FAIL,
    CANTIAN_DDL_TRUNCATE_DATAFILE_BEFORE_SAVE_DF_CTRL_ABORT,
    CANTIAN_DDL_TRUNCATE_DATAFILE_SAVE_DF_CTRL_FAIL,
    CANTIAN_DDL_TRUNCATE_DATAFILE_BEFORE_SYNC_ABORT,
    CANTIAN_DDL_TRUNCATE_DATAFILE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_SPACE_BEFORE_LOGPUT_ABORT,
    CANTIAN_DDL_DROP_SPACE_AFTER_LOGPUT_ABORT,
    CANTIAN_DDL_DROP_SPACE_FAIL,
    CANTIAN_DDL_DROP_SPACE_SAVE_CTRL_FAIL,
    CANTIAN_DDL_DROP_SPACE_AFTER_SYNC_ABORT,
    CANTIAN_DDL_DROP_SPACE_BEFORE_WRITE_CTRL_ABORT,
    CANTIAN_DDL_DROP_SPACE_AFTER_WRITE_CTRL_ABORT,
    CANTIAN_LOCK_TABLE_X_LOCAL_BEFORE_ABORT,
    CANTIAN_LOCK_TABLE_X_LOCAL_AFTER_ABORT,
    CANTIAN_LOCK_TABLE_X_DLS_AFTER_ABORT,
    CANTIAN_LOCK_TABLE_S_LOCAL_BEFORE_ABORT,
    CANTIAN_LOCK_TABLE_S_LOCAL_AFTER_ABORT,
    CANTIAN_LOCK_TABLE_S_DLS_AFTER_ABORT,
    CANTIAN_DDL_BEFORE_SYNC_DDL_ABORT,
    CANTIAN_DDL_AFTER_SYNC_DDL_ABORT,
    CANTIAN_GET_USER_STATS_ACK_TIMEOUT,
    CANTIAN_SET_USER_STATS_ACK_TIMEOUT,
    CANTIAN_CREATE_DB_4MYSQL_LOCK_FAIL,
    CANTIAN_CREATE_DB_4MYSQL_CREATE_SPC_FAIL,
    CANTIAN_CREATE_DB_4MYSQL_CREATE_USER_FAIL,
    CANTIAN_DROP_DB_4MYSQL_LOCK_FAIL,
    CANTIAN_DROP_DB_4MYSQL_DROP_USER_FAIL,
    CANTIAN_DROP_DB_4MYSQL_DROP_SPC_FAIL,
    CANTIAN_CREATE_DB_4MYSQL_AFTER_LOCK_ABORT,
    CANTIAN_CREATE_DB_4MYSQL_BEFORE_CREATE_SPC_ABORT,
    CANTIAN_CREATE_DB_4MYSQL_AFTER_CREATE_SPC_ABORT,
    CANTIAN_CREATE_DB_4MYSQL_BEFORE_CREATE_USER_ABORT,
    CANTIAN_CREATE_DB_4MYSQL_AFTER_CREATE_USER_ABORT,
    CANTIAN_CREATE_DB_4MYSQL_BEFORE_CREATE_USER_DELAY,
    CANTIAN_DROP_DB_4MYSQL_AFTER_LOCK_ABORT,
    CANTIAN_DROP_DB_4MYSQL_BEFORE_DROP_USER_ABORT,
    CANTIAN_DROP_DB_4MYSQL_AFTER_DROP_USER_ABORT,
    CANTIAN_DROP_DB_4MYSQL_BEFORE_DROP_SPC_ABORT,
    CANTIAN_DROP_DB_4MYSQL_AFTER_DROP_SPC_ABORT,
    CANTIAN_DROP_DB_4MYSQL_AFTER_DROP_USER_DELAY,
    CTC_MES_UNLOCK_TABLE_SUCC_ABORT,
    CTC_LOCK_TABLE_SUCC_ABORT,
    CTC_DDL_SUCC_ABORT,
    CTC_CLOSE_CONN_SUCC_ABORT,
    CTC_MES_OVERVIEW_SEND_FAIL,
    CTC_MES_OVERVIEW_RECV_FAIL,
    CTC_LOCK_TABLE_REMOTE_ABORT,
    CTC_EXECUTE_DDL_REMOTE_ABORT,
    CTC_UNLOCK_REMOTE_ABORT,
    CTC_CLOSE_CONN_ABORT,

    CTC_RENAME_CROSS_DB_AFTER_CREATE_TABLE_ABORT,
    CTC_RENAME_CROSS_DB_AFTER_FILL_DATA_ABORT,
    CTC_RENAME_CROSS_DB_AFTER_DROP_OLD_TABLE_ABORT,
    CTC_RENAME_CROSS_DB_FILL_PART_FAIL,
    CTC_RENAME_CROSS_DB_FILL_FK_FAIL,
    CTC_RENAME_CROSS_DB_FILL_INDEX_FAIL,
    CTC_RENAME_CROSS_DB_DELAY,
    CTC_RENAME_CROSS_DB_LOCK_USER_DELAY,

    CANTIAN_BACKUP_REV_PRECHECK_STAT_REQ_ABORT,
    CANTIAN_BACKUP_REV_PRECHECK_ARCH_REQ_ABORT,
    CANTIAN_BACKUP_TRIGGER_FORCH_ARCH_ABORT,
    CANTIAN_BACKUP_TRIGGER_FORCH_ARCH_WAIT_ABORT,
    CANTIAN_BACKUP_TRIGGER_CKPT_ABORT,
    CANTIAN_BACKUP_REV_LSN_REQ_ABORT,
    CANTIAN_BACKUP_REV_RCY_REQ_ABORT,
    CANTIAN_BACKUP_REV_LRP_REQ_ABORT,
    CANTIAN_BACKUP_REV_CTRL_REQ_ABORT,
    CANTIAN_BACKUP_REV_CKPT_REQ_FAIL,
    CANTIAN_BACKUP_READ_PAGE_FROM_DBSTOR_FAIL,
    CANTIAN_BACKUP_WRITE_PAGE_TO_FILE_FAIL,
    CANTIAN_BACKUP_WRITE_CTRL_TO_FILE_FAIL,
    CANTIAN_BACKUP_WRITE_BACKUPSET_TO_FILE_FAIL,
    CANTIAN_BACKUP_READ_LOG_FROM_ARCH_FAIL,
    CANTIAN_BACKUP_WRITE_LOG_TO_FILE_FAIL,

    CANTIAN_ARCH_GET_LOG_CAPACITY_FAIL,
    CANTIAN_ARCH_GET_LOG_FAIL,
    CANTIAN_ARCH_WRITE_LOG_TO_FILE_FAIL,
    CANTIAN_ARCH_RENAME_TMP_FILE_FAIL,
    CANTIAN_REFORM_ARCHIVE_INIT_ARCH_CTX_FAIL,
    CANTIAN_REFORM_ARCHIVE_READ_REDO_LOG_FAIL,

    CANTIAN_RST_OPEN_NAMESPACE_FAIL,
    CANTIAN_SPC_OPEN_DATAFILE_FAIL,

    CTC_CREATE_TABLE_BEFORE_KNL_CREATE_ABORT,
    CTC_CREATE_TABLE_AFTER_KNL_CREATE_ABORT,
    CTC_CREATE_TABLE_4MYSQL_FAIL,

    CTC_ALTER_TABLE_BEFORE_KNL_ALTER_ABORT,
    CTC_ALTER_TABLE_AFTER_KNL_ALTER_ABORT,
    CTC_ALTER_TABLE_4MYSQL_FAIL,

    CTC_RENAME_TABLE_BEFORE_KNL_RENAME_ABORT,
    CTC_RENAME_TABLE_AFTER_KNL_RENAME_ABORT,
    CTC_RENAME_TABLE_4MYSQL_FAIL,

    CTC_DROP_TABLE_BEFORE_KNL_DROP_ABORT,
    CTC_DROP_TABLE_AFTER_KNL_DROP_ABORT,
    CTC_DROP_TABLE_4MYSQL_FAIL,
    CANTIAN_OPEN_DEVICE_FAIL,

    CANTIAN_UPGRADE_CTRL_VERSION_LOCK_DDL_FAIL,
    CANTIAN_UPGRADE_CTRL_VERSION_WRITE_DISK_FAIL,
    CANTIAN_UPGRADE_CTRL_VERSION_BEFORE_WRITE_DISK_ABORT,
    CANTIAN_UPGRADE_CTRL_VERSION_AFTER_WRITE_DISK_ABORT,
    CANTIAN_UPGRADE_CTRL_VERSION_SEND_SYNC_FAIL,
    CANTIAN_UPGRADE_CTRL_VERSION_SEND_ACK_FAIL,
    CANTIAN_RD_DROP_TABLE_DELAY,
    CANTIAN_BEFORE_RD_DROP_TABLE_DELAY,
    CTC_CRETAE_TABLE_STATS_ACK_TIMEOUT,
    CTC_ALTER_TABLE_STATS_ACK_TIMEOUT,
    CTC_RENAME_TABLE_STATS_ACK_TIMEOUT,
    CTC_DROP_TABLE_STATS_ACK_TIMEOUT,

    CTC_COMMIT_LOG_PUT_FAIL,
    CANTIAN_DDL_ROLLBACK_DROP_GARBAGE_TABLE_FAIL,
    CANTIAN_DDL_DELETE_GARBAGE_TABLE_4COMMIT_FAIL,
    CANTIAN_DDL_DELETE_GARBAGE_TABLE_4DROP_TABLE_FAIL,
    CANTIAN_DDL_TRUNCATE_TABLE_PRECHECK_FAIL,
    CANTIAN_DDL_TRUNCATE_TABLE_FAIL,
    CANTIAN_KNL_COMMIT_DELAY,
    CANTIAN_KNL_COMMIT_DELAY_ONCE,
    CANTIAN_DDL_TABLE_BEFORE_COMMIT_ABORT,
    CANTIAN_DDL_TABLE_AFTER_COMMIT_ABORT,
    CTC_BEFORE_INVALID_MYSQL_CACHE_ABORT,
    CTC_INVALID_MYSQL_CACHE_FAIL,
    CTC_AFTER_INVALID_MYSQL_CACHE_ABORT,
    CANTIAN_REFORM_BUILD_CHANNEL_DELAY,
    CANTIAN_REFORM_BUILD_CHANNEL_ABORT,
    CANTIAN_BACKUP_DBS_IOF_FAIL,
    CANTIAN_BACKUP_CORE_LOG_INFO_FAIL,
    CANTIAN_CKPT_CHECKSUM_VERIFY_FAIL,
    COLLECT_STATISTICS_CREATE_TEMP_TABLE_FAIL,
    COLLECT_STATISTICS_COLLECT_SAMPLED_DATA_FAIL,
    COLLECT_STATISTICS_ANALYZED_DATA_FAIL,
    COLLECT_STATISTICS_INDEX_FAIL,
    COLLECT_STATISTICS_PERSISTENCE_THROUGH_RESULT_FAIL,

    CTC_FILL_CBO_STATS_COL_FAIL,
    CTC_FILL_CBO_STATS_INDEX_FAIL,
    CTC_GET_CBO_STATS_FAIL,
    CTC_UNLOCK_MDL_KEY_ABORT,
    CTC_BACKUP_STOP_REDO_RECYCLE_ABORT,
    CTC_BACKUP_START_REDO_RECYCLE_ABORT,

    CANTIAN_REFORM_BETWEEN_REMASTER_AND_RECOVERY_DELAY,
} knl_syncpoint_id;

typedef void (*syncpoint_callback)(int32 *param, int32 ret);
typedef struct st_knl_syncpoint_def {
    uint32 id;
    bool32 flag;
    char name[KNL_MAX_SYNCPOINT_NAME_LEN];
    uint32 count; // match count
    syncpoint_callback op;
    spinlock_t lock;
} knl_global_syncpoint_def;

status_t sp_exec_global_syncpoint(uint32 sp_id, int32 *user_param, int32 ret);
 
status_t sp_set_global_syncpoint(syncpoint_def_t *syncpoint_def);

bool32 sp_get_global_syncpoint_flag(uint32 sp_id);

uint32 sp_get_global_syncpoint_count(uint32 sp_id);

const char *sp_get_global_syncpoint_name(uint32 sp_id);

uint32 sp_get_global_syncpoint_total_count(void);

/* sync point section */
#define CT_SESSION_MAX_SYNCPOINT      10
#define CT_CONCURRENT_MAX_SYNCPOINT   0x80
#define INVALID_SYNCPOINT_INDEX       CT_SESSION_MAX_SYNCPOINT
#define INDEX_IS_INVALID(inx)         ((inx) == INVALID_SYNCPOINT_INDEX)

typedef struct st_syncpoint_action {
    uint32 active_syncpoint;
    syncpoint_def_t syncpoint_def[CT_SESSION_MAX_SYNCPOINT];
} syncpoint_action_t;

typedef struct st_syncpoint {
    spinlock_t syncpoint_lock;
    uint32 num_signal;
    char signals[CT_CONCURRENT_MAX_SYNCPOINT * CT_NAME_BUFFER_SIZE];
} syncpoint_t;

status_t sp_add_syncpoint(knl_handle_t knl_session, syncpoint_def_t *syncpoint_def);
status_t sp_reset_syncpoint(knl_handle_t knl_session);
status_t sp_exec_syncpoint(knl_handle_t knl_session, const char *syncpoint_name);
void     sp_clear_syncpoint_action(knl_handle_t knl_session);
#endif /* DB_DEBUG_VERSION */

#ifdef __cplusplus
}
#endif

#endif
